package com.hxy.manager;

import android.Manifest;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageManager;

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.hxy.manager.activity.goods.GoodsAddActivity;
import com.hxy.manager.entity.DaoMaster;
import com.hxy.manager.entity.DaoSession;
import com.hxy.manager.util.Constant;
import com.simple.spiderman.SpiderMan;

import org.greenrobot.greendao.database.Database;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class App extends Application {
    private static Context context;

    public static Context getAppContext() {
        return context;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
        //放在其他库初始化前，用于崩溃日志获取的
        SpiderMan.init(this);
        Logger log = LoggerFactory.getLogger(App.class);
        log.info("hello world");
        initGreenDao();


    }

    private void initGreenDao() {

        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, Constant.SQLITE_DATABASE, null);

        Database dataBase = helper.getWritableDb();
//        Database dataBase = helper.getEncryptedWritableDb();

        DaoSession daoSession = new DaoMaster(dataBase).newSession();
        daoSession.clear();
    }
}